<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Shared.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <!-- SimpleStyles: Menu -->
  <Style x:Key="{x:Type Menu}" TargetType="Menu">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="Menu">
          <Border 
            Background="{StaticResource NormalBrush}"
            BorderBrush="{StaticResource NormalBorderBrush}"
            Padding="{TemplateBinding Padding}"
            BorderThickness="1">
            <StackPanel ClipToBounds="True" Orientation="Horizontal" IsItemsHost="True"/>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  
  <!-- SimpleStyles: ContextMenu -->
  <Style TargetType="ContextMenu">
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
    <Setter Property="HasDropShadow" Value="True"/>
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="ContextMenu">
          <Border 
            Name="Border"
            Padding="0,2,0,2" 
            CornerRadius="4" 
            Background="{StaticResource ItemsBackgroundBrush}"
            BorderBrush="{StaticResource SolidBorderBrush}"
            BorderThickness="1" >
            <!--
            <StackPanel IsItemsHost="True"
                        Margin="{TemplateBinding Padding}"
                        KeyboardNavigation.DirectionalNavigation="Cycle"/>
            -->
            <ScrollViewer CanContentScroll="True"
                          Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
              <ItemsPresenter Margin="{TemplateBinding Padding}"
                              KeyboardNavigation.DirectionalNavigation="Cycle"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </ScrollViewer>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="HasDropShadow" Value="false">
              <Setter TargetName="Border" Property="BitmapEffect" Value="{x:Null}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  
  <!-- SimpleStyles: MenuItem -->
  <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
         TargetType="Separator">
    <Setter Property="Height" Value="1"/>
    <Setter Property="Margin" Value="1,4,1,4"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="Separator">
          <Border BorderBrush="{StaticResource SolidBorderBrush}"
                  BorderThickness="1"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- TopLevelHeader -->
  <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}"
                   TargetType="MenuItem">
    <Border Name="Border" CornerRadius="2,2,0,0" BorderThickness="1" BorderBrush="Transparent">
      <Grid Margin="{TemplateBinding MenuItem.Padding}">
        <ContentPresenter 
          ContentSource="Header"
          RecognizesAccessKey="True" />
        <Popup 
          Name="PART_Popup"
          HorizontalOffset="-7"
          VerticalOffset="3"
          Placement="Bottom"
          IsOpen="{TemplateBinding IsSubmenuOpen}"
          AllowsTransparency="True" 
          Focusable="False"
          PopupAnimation="Fade">
          <Border 
            Name="SubmenuBorder"
            SnapsToDevicePixels="True"
            Background="{StaticResource ItemsBackgroundBrush}"
            BorderBrush="{StaticResource SolidBorderBrush}"
            BorderThickness="1" 
            CornerRadius="0,2,2,2"
            Padding="0,2,0,2">
            <!--
            <StackPanel  
              IsItemsHost="True" 
              KeyboardNavigation.DirectionalNavigation="Cycle" />
             -->
            <ScrollViewer CanContentScroll="true"
                          Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
              <ItemsPresenter KeyboardNavigation.TabNavigation="Cycle"
                              KeyboardNavigation.DirectionalNavigation="Cycle"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Grid.IsSharedSizeScope="true"/>
            </ScrollViewer>
          </Border>
        </Popup>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="IsSuspendingPopupAnimation" Value="true">
        <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None"/>
      </Trigger>
      <Trigger Property="IsHighlighted" Value="true">
        <Setter TargetName="Border" Property="Background"
                Value="{StaticResource SelectedFocusBackgroundBrush}"/>
        <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource SolidBorderBrush}"/>
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  
  <!-- TopLevelItem -->

  <ControlTemplate 
    x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" 
    TargetType="MenuItem">
    <Border Name="Border" CornerRadius="2">
      <Grid Margin="{TemplateBinding MenuItem.Padding}" >
        <ContentPresenter 
          ContentSource="Header"
          RecognizesAccessKey="True" />
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="IsHighlighted" Value="true">
        <Setter TargetName="Border" Property="Background"
                Value="{StaticResource SelectedFocusBackgroundBrush}"/>
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground"
                Value="{StaticResource DisabledForegroundBrush}"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <!-- SubmenuItem -->

  <ControlTemplate 
    x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" 
    TargetType="MenuItem">
    <Border Name="Border" CornerRadius="2">
      <Grid Margin="{TemplateBinding MenuItem.Padding}">
        <!--
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
          <ColumnDefinition Width="13"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter 
          Name="Icon"
          Margin="6,0,6,0"
          VerticalAlignment="Center"
          ContentSource="Icon"/>
        <Border 
          Name="Check"  
          Width="13" Height="13" 
          Visibility="Collapsed"
          Margin="6,0,6,0" 
          Background="{StaticResource NormalBrush}"
          BorderThickness="1"
          BorderBrush="{StaticResource NormalBorderBrush}">
          <Path 
            Name="CheckMark"
            Width="7" Height="7" 
            Visibility="Hidden" 
            SnapsToDevicePixels="False" 
            Stroke="{StaticResource GlyphBrush}"
            StrokeThickness="2"
            Data="M 0 0 L 7 7 M 0 7 L 7 0" />
        </Border>
        <ContentPresenter 
          Name="HeaderHost"
          Grid.Column="1"
          ContentSource="Header"
          RecognizesAccessKey="True"/>
        <TextBlock x:Name="InputGestureText"
          Grid.Column="2"
          Text="{TemplateBinding InputGestureText}"
          Margin="5,2,0,2"
          DockPanel.Dock="Right" />
        -->
        <Grid.ColumnDefinitions>
          <ColumnDefinition MinWidth="24"
                            Width="Auto"
                            SharedSizeGroup="MenuItemIconColumnGroup"/>
          <ColumnDefinition Width="3"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="20"/>
          <ColumnDefinition Width="Auto"
                            SharedSizeGroup="MenuItemIGTColumnGroup"/>
          <ColumnDefinition Width="17"/>
        </Grid.ColumnDefinitions>
        <Grid>
          <ContentPresenter x:Name="Icon"
                            Margin="1"
                            VerticalAlignment="Center"
                            ContentSource="Icon"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          <Border
            Name="GlyphPanel"
            Width="13" Height="13"
            Visibility="Collapsed"
            Margin="6,0,6,0"
            Background="{StaticResource NormalBrush}"
            BorderThickness="1"
            BorderBrush="{StaticResource SolidBorderBrush}">
            <Path
              Name="Glyph"
              Width="7" Height="7"
              Visibility="Hidden"
              SnapsToDevicePixels="False"
              Stroke="{StaticResource GlyphBrush}"
              StrokeThickness="2"
              Data="M 0 0 L 7 7 M 0 7 L 7 0" />
          </Border>
        </Grid>
        <ContentPresenter Grid.Column="2"
                          ContentSource="Header"
                          RecognizesAccessKey="True"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <TextBlock Grid.Column="4"
                   TextAlignment="Right"
                   Text="{TemplateBinding MenuItem.InputGestureText}"/>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="Icon" Value="{x:Null}">
        <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsChecked" Value="true">
        <Setter TargetName="Glyph" Property="Visibility" Value="Visible"/>
      </Trigger>
      <Trigger Property="IsCheckable" Value="true">
        <Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible"/>
        <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsHighlighted" Value="true">
        <Setter TargetName="Border" Property="Background"
                Value="{StaticResource SelectedFocusBackgroundBrush}"/>
      </Trigger>
      <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <!-- SubmenuHeader -->

  <ControlTemplate 
    x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" 
    TargetType="MenuItem">
    <Border Name="Border" CornerRadius="2">
      <Grid Margin="{TemplateBinding MenuItem.Padding}">
        <!--
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
          <ColumnDefinition Width="13"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter 
          Name="Icon"
          Margin="6,0,6,0"
          VerticalAlignment="Center"
          ContentSource="Icon"/>
        <ContentPresenter 
          Name="HeaderHost"
          Grid.Column="1"
          ContentSource="Header"
          RecognizesAccessKey="True"/>
        <TextBlock x:Name="InputGestureText"
          Grid.Column="2"
          Text="{TemplateBinding InputGestureText}"
          Margin="5,2,2,2"
          DockPanel.Dock="Right"/>
        <Path 
          Grid.Column="3"
          HorizontalAlignment="Center"
          VerticalAlignment="Center"
          Data="M 0 0 L 0 7 L 4 3.5 Z" 
          Fill="{StaticResource GlyphBrush}" />
        -->
        <Grid.ColumnDefinitions>
          <ColumnDefinition MinWidth="24"
                            Width="Auto"
                            SharedSizeGroup="MenuItemIconColumnGroup"/>
          <ColumnDefinition Width="3"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="20"/>
          <ColumnDefinition Width="Auto"
                            SharedSizeGroup="MenuItemIGTColumnGroup"/>
          <ColumnDefinition Width="17"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter x:Name="Icon"
                          Margin="1"
                          VerticalAlignment="Center"
                          ContentSource="Icon"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <ContentPresenter Grid.Column="2"
                          ContentSource="Header"
                          RecognizesAccessKey="True"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <TextBlock Grid.Column="4"
                   Text="{TemplateBinding MenuItem.InputGestureText}"
                   Visibility="Collapsed"/>
        <Path Grid.Column="5"
          HorizontalAlignment="Center"
          VerticalAlignment="Center"
          Data="M 0 0 L 0 7 L 4 3.5 Z" 
          Fill="{StaticResource GlyphBrush}" />
        <Popup
          Name="PART_Popup"
          Placement="Right"
          HorizontalOffset="-4"
          IsOpen="{TemplateBinding IsSubmenuOpen}"
          AllowsTransparency="True"
          Focusable="False"
          PopupAnimation="Fade">
          <Border
            Name="SubmenuBorder"
            SnapsToDevicePixels="True"
            Background="{StaticResource ItemsBackgroundBrush}"
            BorderBrush="{StaticResource SolidBorderBrush}"
            BorderThickness="1" 
            CornerRadius="2"
            Margin="0,2">
            <!--
            <StackPanel
              IsItemsHost="True"
              KeyboardNavigation.DirectionalNavigation="Cycle" />
            -->
            <ScrollViewer CanContentScroll="true"
                          Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
              <ItemsPresenter KeyboardNavigation.TabNavigation="Cycle"
                              KeyboardNavigation.DirectionalNavigation="Cycle"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Grid.IsSharedSizeScope="true"/>
            </ScrollViewer>
          </Border>
        </Popup>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="Icon" Value="{x:Null}">
        <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsHighlighted" Value="true">
        <Setter TargetName="Border" Property="Background"
                Value="{StaticResource SelectedFocusBackgroundBrush}"/>
      </Trigger>
      <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <!-- MenuItem Style -->

  <Style x:Key="{x:Type MenuItem}" TargetType="MenuItem">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Style.Triggers>
      <Trigger Property="Role" Value="TopLevelHeader">
        <Setter Property="Template"
                Value="{StaticResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}"/>
        <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
        <Setter Property="Padding" Value="6,3"/>
      </Trigger>
      <Trigger Property="Role" Value="TopLevelItem">
        <Setter Property="Template"
                Value="{StaticResource {x:Static MenuItem.TopLevelItemTemplateKey}}"/>
        <Setter Property="Padding" Value="6,3"/>
      </Trigger>
      <Trigger Property="Role" Value="SubmenuHeader">
        <Setter Property="Template"
                Value="{StaticResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}"/>
        <Setter Property="Padding" Value="5,2,0,2"/>
      </Trigger>
      <Trigger Property="Role" Value="SubmenuItem">
        <Setter Property="Template"
                Value="{StaticResource {x:Static MenuItem.SubmenuItemTemplateKey}}"/>
        <Setter Property="Padding" Value="5,2,0,2"/>
      </Trigger>
    </Style.Triggers>
  </Style>

</ResourceDictionary>